#include "signal.h"
#include "unistd.h"
static void my_op(int);
int main( int argc , char ** argv )
{
	sigset_t new_mask,old_mask,pending_mask;
	struct sigaction act;
	int sig = atoi( argv[1] );	
	sigemptyset(&act.sa_mask);
	act.sa_flags=SA_SIGINFO;
	act.sa_sigaction=(void*)my_op;
	 if(sigaction( sig ,&act,NULL))
		printf("install signal sig error\n");
	sigemptyset(&new_mask);
	sigaddset(&new_mask,sig );
	if(sigprocmask(SIG_BLOCK, &new_mask,&old_mask))
		printf("block signal sig error\n");
	sleep(10);	
	printf("now begin to get pending mask and unblock SIGINFO\n");
	if(sigpending(&pending_mask)<0)
		printf("get pending mask error\n");
	if(sigismember(&pending_mask, sig))
		printf("signal SIGINFO is pending\n");
	if(sigprocmask(SIG_SETMASK,&old_mask,NULL)<0)
		printf("unblock signal error\n");
	printf("signal unblocked\n");
	sleep(10);
	printf("exit\n");
	return 0;
}
static void my_op(int signum)
{
	printf("receive signal %d \n",signum);
}

